/*
参考
https://blog.csdn.net/m0_46612221/article/details/122989454
*/

const readline = require("readline");

const question = (title) => {
	return new Promise((ok,fail) => {
		// 创建接口实例
		const r1 = readline.createInterface({
		    input: process.stdin,
		    output: process.stdout
		})
		r1.question(`${title} > `, function (answer) {
			console.log('-->',answer)
		    ok(answer);
		    r1.close();
		})
		//close事件监听
		r1.on("close", function () {
		    // 结束程序
		    process.exit(0);
		})
	});
}
module.exports = {
	question,
}